package tiasw;

/**
 * Title:        Turnout In a Small World
 * Description:  Program to study how neighborhood influence propagates turnout behavior.
 * Copyright:    Copyright (c) 2002
 * Company:      Harvard University
 * @author James Fowler
 * @version 1.0
 */

import java.util.*;

public class Citizen {

  double preference;
  int id;
  boolean turnout;
  boolean initialTurnout;
  ArrayList neighbors;

  public Citizen(int i, double p, boolean t) {
    id = i;
    preference = p;
    initialTurnout = t;
    turnout = t;
    neighbors = new ArrayList();

  }

  public void setPreference( double p) {
    preference = p;
  }

  public void setTurnout( boolean t) {
    turnout = t;
  }

  public void addNeighbor( Citizen c) {
    neighbors.add(c);
  }

  public void removeNeighbor( Citizen c) {
    neighbors.remove(c);
  }

  public int getNumNeighbors() {
    return neighbors.size();
  }

  public int getVote(double a, double b) {
    if ( Math.abs(a - preference)<Math.abs(b - preference))
      return 0;
    else
      return 1;
  }
}